<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>举报</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="/node_modules/LobsterUIFrame/weui/css/weui.css" />
    <link rel="stylesheet" href="/node_modules/LobsterUIFrame/weui/css/weuix.css" />
    <script src="/node_modules/LobsterUIFrame/weui/js/zepto.min.js"></script>
    <script src="/node_modules/LobsterUIFrame/weui/js/zepto.weui.js"></script>
    <script src="/node_modules/LobsterUIFrame/weui/js/swipe.js"></script>
    <script src="/node_modules/LobsterUIFrame/weui/js/macy.js"></script>
    <script src="/node_modules/LobsterUIFrame/weui/js/php.js"></script>
    <script src="/lobstersdk/lobster.js"></script>
    <script src="/jslib/template-web.js"></script>
    <style>

    </style>
</head>

<body ontouchstart class="page-bd-15">
    <div class="weui-cells__title weui-start">举报类型</div>
    <div class="weui-form" id="k1">

    </div>
    <div class="weui-cells__title weui-start">举报内容</div>
    <div class="weui-form">
        <div class="weui-form-li">
            <textarea id="reportdesc" class="weui-form-area" name="f6" rows="5" cols="60"></textarea>
        </div>
    </div>
    <a href="javascript:;" class="weui-btn weui-btn_primary" id="tijiao">提交</a>
</body>

</html>
<script id="typetemp" type="text/html">
    {{each list item}}
    <div class="weui-form"> 
     <div class="weui-form-li iblock">
                <input class="weui-form-checkbox" data-name="{{item.Name}}" name="f2" id="g{{item.Code}}" value="{{item.Code}}" type="radio">
                <label for="g{{item.Code}}">
                    <i class="weui-icon-radio"></i>
                    <div class="weui-form-text">
                        <p>{{item.Name}}</p>
                    </div>
                </label>
            </div></div>
     {{/each}}
</script>
<script>

    lobsterh5.main({
        data: {
            report: {},
        },
        //初始化页面
        pageload: function () {
            this.initevent();
            this.getDic(8149).then(res => {
                var appendhtml = template("typetemp", { list: res.appbasedict });
                $("#k1").html(appendhtml);
            })
        },
        //初始化事件
        initevent: function () {
            var self = this;
            $("#tijiao").click(function () {
                var reporttype = $(".weui-form-checkbox:checked").val();
                var reportcont= $(".weui-form-checkbox:checked").data("name");
                if (!reporttype) {
                    $.toast("请选择举报类型", "text");
                    return;
                }
                var reportdesc = $("#reportdesc").val();
                if (!reportdesc) {
                    $.toast("请填写举报内容", "text");
                    return;
                }
                var userId = localStorage.getItem("userId");
                $.showLoading("举报中。。。");
                lobsterh5.POST("/lowcode/APP20211203093514696/name/?fun=Dynamic.ReportDynamic", {
                    DynamicId:lobsterh5.GetUrlParam("dynamicId"),
                    IsReport: 1,
                    ReportUserId: userId,
                    UserId: userId,
                    ReportType: reporttype,
                    ReportDesc: reportdesc,
                    ReportContent:reportcont
                }).then(res => {
                    $.hideLoading();
                    // $.toast("举报成功", "text");
                    // setTimeout(() => { 
                    //     history.back();
                    // }, 500);
                }).catch(res => {
                    $.hideLoading();
                    $.toast(res.msg||res,"forbidden");
                });
            })
        },
        //获取支付类型字典 
        getDic: function (classId) {
            return new Promise((resolve, reject) => {
                lobsterh5.GET("/common/v1/BasicData/GetAppBaseDict", {
                    classId: classId,
                    appKey: "APP20211203093514696"
                }).then(res => {
                    resolve(res);
                }).catch(res => {
                    reject(res);
                });
            })
        },
    }); 
</script>